function outPut = thin(I)
outPut=I;
[M,N]=size(I);
[X,Y]=size(outPut);
for i=1:X
    for j=1:Y
        outPut(i,j)=255;
    end
end
        
for i=2:M-1
    for j=2:N-1
        if I(i,j)==0
            if (I(i-1,j)==0&&I(i,j+1)==0)||(I(i-1,j)==0&&I(i,j-1)==0)||(I(i+1,j)==0&&I(i,j-1)==0)||(I(i+1,j)==0&&I(i,j+1)==0)
                outPut(i,j)=0;
            else
                outPut(i,j)=1;
            end
        end
    end
end

end
